package com.nuanshui.heatedloan.configBehavior;
import java.util.List;

import com.alibaba.dubbo.config.annotation.Reference;
import com.nuanshui.framework.utils.ReflectionUtils;
import com.nuanshui.heatedloan.baseservice.constant.CommmonConfigType;
import com.nuanshui.heatedloan.baseservice.form.CommonConfigForm;
import com.nuanshui.heatedloan.baseservice.vo.CommonConfigVO;
import com.nuanshui.heatedloan.constant.GlobalParam;
import com.nuanshui.heatedloan.pageable.Pager;
import com.nuanshui.heatedloan.baseservice.facade.CommonConfigService;
import com.nuanshui.framework.behavior.BehaviorAttribute;

/**
 * Created by zxh on 2016/11/19.
 */
@BehaviorAttribute
public class CommonConfigBehavior extends ConfigBehavior {

    @Reference(url = GlobalParam.BASESERVICE_DUBBO_SERVER, timeout = GlobalParam.DUBBO_SERVER_TIME_OUT,version = GlobalParam.BASESERVICE_DUBBO_SERVER_VERSION)
    private CommonConfigService commonConfigService;

    @Override
	public void doInvoke()
    {
        Pager<CommonConfigVO> pager=new Pager<CommonConfigVO>(1,100);
        CommonConfigForm form = new CommonConfigForm();
        form.setType(CommmonConfigType.SYSTEM_TYPE);
        pager = commonConfigService.list(pager,form);

        List<CommonConfigVO> list=pager.getData();
        if (list != null) {
            for (CommonConfigVO item : list) {
                ReflectionUtils.staggedProperties(item,"key","value");
            }
        }


        getMap().put("dictArray",list);
    }
}
